﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Asset
{
    public class Asset<T> : IAsyncAsset where T : UnityEngine.Object
    {
        protected T result;
        public T Result => this.result;

        private IAsyncBundle bundle;
        public IAsyncBundle Bundle => this.bundle;

        public Asset(string name, IAsyncBundle bundle)
        {
            this.resName = name;
            this.bundle = bundle;
            initialize();
        }

        protected virtual void initialize()
        {
            this.result = this.bundle.bundle.LoadAsset<T>(this.resName);
            this.asyncStatus = AsyncStatus.Finish;
        }

        protected AsyncStatus asyncStatus = AsyncStatus.Waiting;
        public AsyncStatus Status => asyncStatus;
        protected string resName;
        public string Name => this.resName;

        public virtual IEnumerator doLoad()
        {
            throw new NotImplementedException();
        }
    }

}
